package com.clotingshoppos.modules.order.entity;

import com.clotingshoppos.common.base.BaseEntity.BaseEntity;

import javax.persistence.*;

/**
 * @ClassName: OrderDetailEntity
 * @Description:
 * @Author: zhandad
 * @Date: 2019-03-25 10:21
 * @Version: v1.0
 */
@Entity
@Table(name = "order_detail", schema = "clothing_shop_pos", catalog = "")
public class OrderDetailEntity extends BaseEntity {
    private String orderId;
    private String product;
    private Integer number;
    private Double totalPrice;

    public OrderDetailEntity(String product, Long number) {
        this.product = product;
        this.number = Math.toIntExact(number);
    }

    public OrderDetailEntity(String product, Long number, Double totalPrice) {
        this.product = product;
        this.number = Math.toIntExact(number);
        this.totalPrice = totalPrice;
    }

    public OrderDetailEntity() {
    }

    @Basic
    @Column(name = "order_id", nullable = true)
    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    @Basic
    @Column(name = "product", nullable = true, length = 45)
    public String getProduct() {
        return product;
    }

    public void setProduct(String product) {
        this.product = product;
    }

    @Basic
    @Column(name = "number", nullable = true)
    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    @Basic
    @Column(name = "total_price", nullable = true, precision = 0)
    public Double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        OrderDetailEntity that = (OrderDetailEntity) o;

        if (id != that.id) return false;
        if (orderId != null ? !orderId.equals(that.orderId) : that.orderId != null) return false;
        if (product != null ? !product.equals(that.product) : that.product != null) return false;
        if (number != null ? !number.equals(that.number) : that.number != null) return false;
        if (totalPrice != null ? !totalPrice.equals(that.totalPrice) : that.totalPrice != null) return false;

        return true;
    }


}
